package com.tuling.jucdemo.threadbase;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * 线程状态测试
 */
@Slf4j
public class ThreadStateTest {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(); //这样写的话就是TERMINATED
//        Thread t1 = new Thread(new Runnable(){
//            @Override
//            public void run() {
//                LockSupport.park();
//            }
//        }); //这样写的话线程结果是 WAITING
        log.debug("线程状态:{}",t1.getState());
        t1.start();
        log.debug("线程状态:{}",t1.getState());
        Thread.sleep(100);
        log.debug("线程状态:{}",t1.getState());
    }
}